package com.jk.bguser.controller;

import com.jk.damaicommon.entity.TicketEntity;
import com.jk.bguser.entity.UserEntity;
import com.jk.bguser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 赵优秀
 * @title
 * @description
 * @updateTime 2021/9/1 10:49
 * @throws
 */

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * @throws
     * @title
     * @description
     * @author 赵优秀
     * @updateTime 2021/9/2 9:17
     */

    //查询
    @GetMapping(value = "findUser")
    public List<UserEntity> findUser(UserEntity userEntity) {
        return userService.findUser(userEntity);
    }

    //批量删除
    @RequestMapping("delAll")
    public void delAll(@RequestParam String ids) {
        userService.delAll(ids);
    }

    //批量冻结
    @RequestMapping("freezeAll")
    public void freezeAll(String ids) {
        userService.freezeAll(ids);
    }

    //逻辑删除
    @RequestMapping("del")
    public void del(@RequestParam Integer id) {
        userService.del(id);
    }

    //冻结
    @RequestMapping("freezeUser")
    public void freezeUser(@RequestParam Integer id) {
        userService.freezeUser(id);
    }

    //解冻
    @RequestMapping("UnFreezeUser")
    public void UnFreezeUser(@RequestParam Integer id) {
        userService.UnFreezeUser(id);
    }

    //回显
    @RequestMapping("getByid")
    public UserEntity getByid(@RequestParam Integer id) {
        return userService.getByid(id);
    }

    //修改
    @PostMapping(value = "updateUser")
    public void updateUser(@RequestBody UserEntity userEntity) {
        userService.updateUser(userEntity);
    }

    //查看冻结用户
    @GetMapping(value = "findFreezeUser")
    public List<UserEntity> findFreezeUser(UserEntity userEntity) {
        return userService.findFreezeUser(userEntity);
    }

    //查看删除用户
    @GetMapping(value = "findDelUser")
    public List<UserEntity> findDelUser(UserEntity userEntity) {
        return userService.findDelUser(userEntity);
    }

    //恢复用户
    @RequestMapping("onUser")
    public void onUser(@RequestParam Integer id) {
        userService.onUser(id);
    }

    //批量回复
    @RequestMapping("onFreezeAll")
    public void onFreezeAll(@RequestParam String ids) {
        userService.onFreezeAll(ids);
    }

    //查询用户优惠券数量
    @RequestMapping("findCoupon")
    public List<UserEntity> findCoupon() {
        return userService.findCoupon();
    }
    /**
     * @title 查询已有的优惠券
     * @description
     * @author 赵优秀
     * @updateTime 2021/9/15 21:17
     * @throws
     */
    @RequestMapping("grantCoupon")
    public List<TicketEntity> grantCoupon(){
        return userService.grantCoupon();
    }
    /**
     * @title 发放优惠券
     * @description
     * @author 赵优秀
     * @updateTime 2021/9/15 22:40
     * @throws
     */
    @PostMapping("grant")
    public String grant(@RequestBody TicketEntity ticket){
        return userService.grant(ticket);
    }
    /**
     * @title 查询用户的优惠券
     * @description
     * @author 赵优秀
     * @updateTime 2021/9/16 10:25
     * @throws
     */
    @RequestMapping("userCoupon")
    public List<TicketEntity> userCoupon(@RequestParam("id") Integer id){
        return userService.userCoupon(id);
    }
}
